import 'package:flutter/material.dart';

class XAppBar extends AppBar {
  XAppBar.noTitle(
      {super.key,
      List<Widget>? actions,
      PreferredSizeWidget? bottom,
      Color backgroundColor = Colors.white,
      Function? backCallBack,
      Color? titleColor,
      Brightness brightness = Brightness.light,
        Widget? leading,
      double elevation = 0})
      : super(
          centerTitle: true,
          // brightness: brightness,
          backgroundColor: backgroundColor,
          elevation: elevation,
          leading: backCallBack == null
              ? Container()
              : InkWell(onTap: () => backCallBack?.call(), child: leading ?? Icon(Icons.arrow_back, size: 26, color: titleColor ?? Colors.black)),
          actions: actions ?? [],
          bottom: bottom,
        );

  XAppBar.normal(
      {super.key,
      List<Widget>? actions,
      PreferredSizeWidget? bottom,
      Color backgroundColor = Colors.white,
      Function? backCallBack,
      Color? titleColor,
      Widget? title,
      Brightness brightness = Brightness.light,
        Widget? leading,
      double elevation = 0})
      : super(
          centerTitle: true,
          title: title,
          // brightness: brightness,
          backgroundColor: backgroundColor,
          elevation: elevation,
          leading: backCallBack == null
              ? Container()
              : InkWell(onTap: () => backCallBack?.call(), child:leading ??  Icon(Icons.arrow_back, size: 26, color: titleColor ?? Colors.black)),
          actions: actions ?? [],
          bottom: bottom,
        );

  XAppBar.title(
      {super.key,
      List<Widget>? actions,
      PreferredSizeWidget? bottom,
      Color backgroundColor = Colors.white,
      Function? backCallBack,
      Function()? titleDoubleClick,
      Color titleColor = Colors.black,
      String? title,
      TextStyle titleStyle = const TextStyle(fontSize: 20, color: Colors.black),
      Brightness brightness = Brightness.light,
      Widget? leading,
      double elevation = 0})
      : super(
          centerTitle: true,
          title: GestureDetector(
            onDoubleTap: titleDoubleClick,
            child: Container(
              child: Text(
                title ?? '',
                overflow: TextOverflow.ellipsis,
                style: titleStyle,
              ),
            ),
          ),
          // brightness: brightness,
          backgroundColor: backgroundColor,
          elevation: elevation,
          leading: backCallBack == null
              ? Container()
              : InkWell(onTap: () => backCallBack?.call(), child: leading ?? Icon(Icons.arrow_back, size: 26, color: titleColor ?? Colors.black)),
          actions: actions ?? [],
          bottom: bottom,
        );

  XAppBar.close(
      {super.key,
      List<Widget>? actions,
      PreferredSizeWidget? bottom,
      Color backgroundColor = Colors.white,
      Function? backCallBack,
      Color titleColor = Colors.black,
      String? title,
      TextStyle titleStyle = const TextStyle(fontSize: 20, color: Colors.black),
      Brightness brightness = Brightness.light,
        Widget? leading,
      double elevation = 0})
      : super(
          centerTitle: true,
          title: Text(
            title ?? '',
            style: titleStyle,
          ),
          // brightness: brightness,
          backgroundColor: backgroundColor,
          elevation: elevation,
          leading: backCallBack == null
              ? Container()
              : InkWell(
                  onTap: () => backCallBack?.call(),
                  child: Container(
                    alignment: Alignment.center,
                    padding: const EdgeInsets.only(left: 16.0, right: 16.0),
                    child: SizedBox(
                      width: 16.0,
                      height: 16.0,
                      child: leading ?? Icon(Icons.arrow_back, size: 26, color: titleColor ?? Colors.black),
                    ),
                  ),
                ),
          actions: actions ?? [],
          bottom: bottom,
        );
}
